package com.yc.class_attendance.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;


import com.yc.class_attendance.R;

import java.util.List;

public class ReGallery_adapter extends BaseAdapter {

	Context context;

	List<Integer>mListR;

	public ReGallery_adapter(Context context, List<Integer>ListR) {
		this.context = context;
		this.mListR =ListR;
	}


	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListR.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mListR.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if(convertView == null || convertView.getTag() == null){
			convertView = LayoutInflater.from(context).inflate(R.layout.gallery_item, parent,false);
			
			viewHolder = new ViewHolder();
			
			viewHolder.gallery_iv = (ImageView) convertView.findViewById(R.id.gallery_iv);

			
			convertView.setTag(viewHolder);
			
		}else{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		if(position==0){
			viewHolder.gallery_iv.setImageResource(R.mipmap.example_one);
		}else if(position==1){
			viewHolder.gallery_iv.setImageResource(R.mipmap.example_two);
		}else if(position==2){
			viewHolder.gallery_iv.setImageResource(R.mipmap.example_three);
		}

//		Glide.with(context).load(mListR.get(position)).into(viewHolder.gallery_iv);
//		Glide.with(context).load(R.drawable.button_login_selector_bg).into(viewHolder.gallery_iv);
//		viewHolder.gallery_iv.setImageResource(Integer.parseInt(list.get(position).toString()));
		return convertView;
	}
	
	class ViewHolder{
		ImageView gallery_iv;
	}

}
